<include file="header" />
<head>
	<link rel="stylesheet" href="/assets/base/repair/js/sweetalert/lib/sweet-alert.css">
</head>
<body>
<div class="wraper">
	<div class="top">
		<p>全部订单</p>
	</div>
	<input type="hidden" value="{BEESCRM:$pageCount}" id="page_count">
	<input type="hidden" id="res_id" value="{BEESCRM:$res_id}">
	<div class="datalist">
	<volist name="data" id="vo">
		<div class="order-dtl">
			<p>订单编号：{BEESCRM:$vo.order_sn}</p>
			<p>下单时间：{BEESCRM:$vo.pay_time|date='Y-m-d H:i',###}</p>
			<hr/>
			<p>收货人：{BEESCRM:$vo.user_name}</p>
			<p>联系电话：<if condition="$vo['mobile']"><a href="tel://{BEESCRM:$vo.mobile}">{BEESCRM:$vo.mobile}</a><span class="iconfont icon-dianhua1" style="color: #4ba63d;"></span></if></p>
			<p>收货地址：{BEESCRM:$vo.address}</p>
			<hr/>
			<p class="text-gray btm10">菜单详情：</p>
			<volist name="vo.RestaurantOrderGoods" id="vol">
				<p>{BEESCRM:$vol.goods_name}<span class="pull-right">x{BEESCRM:$vol.goods_num}</span></p>
			</volist>
			<hr/>
			<p class="text-gray btm10">买家备注：</p>
			<p>{BEESCRM:$vo.memo}</p>
			<hr/>

			<if condition="$vo['status'] eq 1">
				<a href="javascript:void(0);" class="c-btn send" data-id="{BEESCRM:$vo.order_id}">确认发货</a>
			</if>
			<if condition="$vo['status'] eq 2">
				<p class="text-gray text-center">已发货</p>
			</if>
			<if condition="$vo['status'] eq 3">
				<p class="text-gray text-center">已确认收货</p>
			</if>
			<if condition="$vo['status'] eq 4">
				<p class="text-gray text-center">已完成</p>
			</if>
		</div>
		<div class="wave-bottom"></div>
	</volist>
		</div>
</div>

<include file="commonJS" />
<script src="/assets/activity/vote/js/classie.js"></script>
<script src="/assets/base/restaurant/js/order.js"></script>
<script src="/assets/activity/vote/js/modalEffects.js"></script>
<script>
	$(function(){
		$(document).on('click','.send',function(){
			var id = $(this).data('id');
			var res_id = $('#res_id').val();
			$.confirm('确认发货吗？', drop);
			function drop() {
				var json = {};
				var data = {};
				data.id = id;
				json.data = data;
				json.url = '/base/restaurant/send/res_id/'+res_id;
				json.method = 'post';
				json.type = 'json';
				$.getAjax(json, true, reload, '');
			}
		});
	});

	//页面刷新
	function reload(){
		setTimeout('location.reload()',1000);
	}

	$(function(){
		$('.classify-box').on('click','.classify-list',function(){
			$(this).addClass('check').siblings().removeClass('check');
		});

		var page = 1;
		var pageCount = $("#page_count").val();
		var res_id = $('#res_id').val();
		$(window).scroll(function() {
			//当内容滚动到底部时加载新的内容
			if ($(window).scrollTop() + $(window).height() + 20 > $(document).height()) {
				//当前要加载的页码
				page++;
				if(page <= pageCount){
					LoadPage(page,res_id);
				}
			}
		});

		function LoadPage(page,res_id) {
			$.ajax({
				'url': "/base/restaurant/ajaxGetList?res_id="+res_id,
				'data': {p: page},
				'dataType': 'json',
				'type': 'GET',
				'async': false,
				success: function (data) {
					if (data.status == 'S') {
						var info = data.data;
						var string = '';
						$(info).each(function (idx) {
							var val = info[idx];
							var str = '';
							if(val.status == 1){
								str = '<a href="javascript:void(0);" class="c-btn send" data-id="'+val.order_id+'">确认发货</a>';
							}else if(val.status == 2){
								str = '<p class="text-gray text-center">已发货</p>';
							}else if(val.status == 3){
								str = '<p class="text-gray text-center">已确认收货</p>';
							}else if(val.status == 4){
								str = '<p class="text-gray text-center">已完成</p>';
							}
							
							string = string+'<div class="order-dtl">'
							+'<p>订单编号：'+val.order_sn+'</p>'
							+'<p>下单时间：'+val.pay_time+'</p>'
							+'<hr/>'
							+'<p>收货人：'+val.user_name+'</p>'
							+'<p>联系电话：'+val.mobile+'</p>'
							+'<p>收货地址：'+val.address+'</p>'
							+'<hr/>'
							+'<p class="text-gray btm10">菜单详情：</p>'
							+val.goods_info+'<hr/>'
							+str+'</div>'
							+'<div class="wave-bottom"></div>';
						});
						$('.datalist').append(string);
					}
				}
			});
		}
	})
</script>
</body>
</html>
